package com.cictec.middleware.gps.engine.thread;
import java.util.Date;
import java.util.concurrent.Callable;

import com.cictec.middleware.gps.engine.TimeEventBus;
import com.cictec.middleware.gps.engine.TimingObject;
import com.cictec.middleware.gps.engine.TimingPoint;
import com.cictec.middleware.gps.engine.TimingPointEvent;

public class PointExecutorCallable implements Callable<Boolean> {

	private TimeEventBus timeEventBus;
	private TimingObject timingObject;

	public PointExecutorCallable(TimingObject timingObject, TimeEventBus timeEventBus) {
		this.timingObject = timingObject;
		this.timeEventBus = timeEventBus;
	}

	@Override
	public Boolean call() {
		try {
			if(timingObject instanceof TimingPoint){
				
				TimingPointEvent event = new TimingPointEvent(new Date(), (TimingPoint) timingObject);
				timeEventBus.post(event);
			}
			return true;
		} catch (Exception e) {
//			e.printStackTrace();
			return false;
		}
	}
}
